package com.mzy.basics.utils.Sql;

import org.springframework.util.StringUtils;

/**
 * @author Ives
 * * @date 2022/1/11
 */
public class reguler {
  public static String replaceUnderlineOrPercent(String content) {
    /**
     * 简单类型
     */
//    String SOURCE_UNDERLINE = "_";
//    String SOURCE_PERCENT = "%";
//    String SOURCE_SLASHLINE = "\\\\";
//    String TARGET_UNDERLINE = "\\\\_";
//    String TARGET_PERCENT = "\\\\%";
//    String TARGET__SLASHLINE = "\\\\\\\\";
    if (StringUtils.hasText(content)) {
      String result = content.replaceAll("\\\\", "\\\\\\\\").replaceAll("_", "\\\\_").replaceAll("%", "\\\\%");
      return result;
    } else {
      return content;
    }
  }
}
